﻿using System;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;

namespace WeiSha.Core.Param.Method
{
	// Token: 0x02000035 RID: 53
	public class ConvertToAnyValue
	{
		// Token: 0x170000C2 RID: 194
		// (get) Token: 0x06000207 RID: 519 RVA: 0x0000EBFC File Offset: 0x0000CDFC
		// (set) Token: 0x06000208 RID: 520 RVA: 0x0000EC19 File Offset: 0x0000CE19
		public string ParaValue
		{
			get
			{
				return this._paravlue.ToString();
			}
			set
			{
				this._paravlue = value;
			}
		}

		// Token: 0x170000C3 RID: 195
		// (get) Token: 0x06000209 RID: 521 RVA: 0x0000EC24 File Offset: 0x0000CE24
		// (set) Token: 0x0600020A RID: 522 RVA: 0x0000EC3C File Offset: 0x0000CE3C
		public string ParaKey
		{
			get
			{
				return this._parakey;
			}
			set
			{
				this._parakey = value;
			}
		}

		// Token: 0x170000C4 RID: 196
		// (get) Token: 0x0600020B RID: 523 RVA: 0x0000EC48 File Offset: 0x0000CE48
		// (set) Token: 0x0600020C RID: 524 RVA: 0x0000EC60 File Offset: 0x0000CE60
		public string Unit
		{
			get
			{
				return this._unit;
			}
			set
			{
				this._unit = value;
			}
		}

		// Token: 0x0600020D RID: 525 RVA: 0x0000EC6A File Offset: 0x0000CE6A
		public ConvertToAnyValue()
		{
		}

		// Token: 0x0600020E RID: 526 RVA: 0x0000EC8A File Offset: 0x0000CE8A
		public ConvertToAnyValue(object para)
		{
			this._paravlue = para;
		}

		// Token: 0x0600020F RID: 527 RVA: 0x0000ECB1 File Offset: 0x0000CEB1
		public ConvertToAnyValue(string para)
		{
			this._paravlue = (string.IsNullOrWhiteSpace(para) ? "" : para);
		}

		// Token: 0x06000210 RID: 528 RVA: 0x0000EC8A File Offset: 0x0000CE8A
		public ConvertToAnyValue(string para, string unit)
		{
			this._paravlue = para;
		}

		// Token: 0x06000211 RID: 529 RVA: 0x0000ECE8 File Offset: 0x0000CEE8
		public static ConvertToAnyValue Get(string para)
		{
			return new ConvertToAnyValue(para);
		}

		// Token: 0x170000C5 RID: 197
		// (get) Token: 0x06000212 RID: 530 RVA: 0x0000ED00 File Offset: 0x0000CF00
		public int? Int16
		{
			get
			{
				bool flag = this._paravlue == null;
				int? num;
				if (flag)
				{
					num = null;
				}
				else
				{
					try
					{
						num = new int?((int)Convert.ToInt16(this._paravlue));
					}
					catch
					{
						Regex regex = new Regex("\\d+");
						Match match = regex.Match(this.String);
						bool success = match.Success;
						if (success)
						{
							string value = match.Groups[0].Value;
							num = new int?((int)Convert.ToInt16(value));
						}
						else
						{
							num = null;
						}
					}
				}
				return num;
			}
		}

		// Token: 0x170000C6 RID: 198
		// (get) Token: 0x06000213 RID: 531 RVA: 0x0000EDA8 File Offset: 0x0000CFA8
		public int? Int32
		{
			get
			{
				bool flag = this._paravlue == null;
				int? num;
				if (flag)
				{
					num = null;
				}
				else
				{
					try
					{
						num = new int?(Convert.ToInt32(this._paravlue));
					}
					catch
					{
						Regex regex = new Regex("\\d+");
						Match match = regex.Match(this.String);
						bool success = match.Success;
						if (success)
						{
							string value = match.Groups[0].Value;
							num = new int?(Convert.ToInt32(value));
						}
						else
						{
							num = null;
						}
					}
				}
				return num;
			}
		}

		// Token: 0x170000C7 RID: 199
		// (get) Token: 0x06000214 RID: 532 RVA: 0x0000EE50 File Offset: 0x0000D050
		public long? Int64
		{
			get
			{
				bool flag = this._paravlue == null;
				long? num;
				if (flag)
				{
					num = null;
				}
				else
				{
					try
					{
						num = new long?(Convert.ToInt64(this._paravlue));
					}
					catch
					{
						Regex regex = new Regex("\\d+");
						Match match = regex.Match(this.String);
						bool success = match.Success;
						if (success)
						{
							string value = match.Groups[0].Value;
							num = new long?(Convert.ToInt64(value));
						}
						else
						{
							num = null;
						}
					}
				}
				return num;
			}
		}

		// Token: 0x170000C8 RID: 200
		// (get) Token: 0x06000215 RID: 533 RVA: 0x0000EEF8 File Offset: 0x0000D0F8
		public double? Double
		{
			get
			{
				bool flag = this._paravlue == null;
				double? num;
				if (flag)
				{
					num = null;
				}
				else
				{
					try
					{
						num = new double?(Convert.ToDouble(this._paravlue));
					}
					catch
					{
						num = null;
					}
				}
				return num;
			}
		}

		// Token: 0x170000C9 RID: 201
		// (get) Token: 0x06000216 RID: 534 RVA: 0x0000EF54 File Offset: 0x0000D154
		public string String
		{
			get
			{
				return (this._paravlue == null) ? "" : this._paravlue.ToString().Trim();
			}
		}

		// Token: 0x170000CA RID: 202
		// (get) Token: 0x06000217 RID: 535 RVA: 0x0000EF88 File Offset: 0x0000D188
		public string Text
		{
			get
			{
				string @string = this.String;
				bool flag = string.IsNullOrWhiteSpace(@string);
				string text;
				if (flag)
				{
					text = @string;
				}
				else
				{
					string text2 = Regex.Replace(@string, "<[^>]+>", "");
					text2 = Regex.Replace(text2, "&[^;]+;", "");
					text = @string;
				}
				return text;
			}
		}

		// Token: 0x170000CB RID: 203
		// (get) Token: 0x06000218 RID: 536 RVA: 0x0000EFD4 File Offset: 0x0000D1D4
		public string Value
		{
			get
			{
				string @string = this.String;
				bool flag = string.IsNullOrWhiteSpace(@string);
				string text;
				if (flag)
				{
					text = null;
				}
				else
				{
					text = @string;
				}
				return text;
			}
		}

		// Token: 0x170000CC RID: 204
		// (get) Token: 0x06000219 RID: 537 RVA: 0x0000EFFC File Offset: 0x0000D1FC
		public bool? Boolean
		{
			get
			{
				bool flag = this._paravlue == null;
				bool? flag2;
				if (flag)
				{
					flag2 = null;
				}
				else
				{
					try
					{
						flag2 = new bool?(Convert.ToBoolean(this._paravlue));
					}
					catch
					{
						flag2 = null;
					}
				}
				return flag2;
			}
		}

		// Token: 0x170000CD RID: 205
		// (get) Token: 0x0600021A RID: 538 RVA: 0x0000F058 File Offset: 0x0000D258
		public DateTime? DateTime
		{
			get
			{
				bool flag = this._paravlue == null;
				DateTime? dateTime;
				if (flag)
				{
					dateTime = null;
				}
				else
				{
					try
					{
						bool flag2 = this._paravlue is long;
						if (flag2)
						{
							long num = 0L;
							long.TryParse(this._paravlue.ToString(), out num);
							DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds((double)num);
							dateTime = new DateTime?(dateTime2);
						}
						else
						{
							dateTime = new DateTime?(global::System.DateTime.ParseExact(this._paravlue.ToString(), "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture));
						}
					}
					catch
					{
						string text = this._paravlue.ToString();
						foreach (char c in text)
						{
							text += ((c >= '0' && c <= '9') ? c : '-').ToString();
						}
						string text3 = text;
						Regex regex = new Regex("\\-{1,}", RegexOptions.IgnorePatternWhitespace);
						text3 = regex.Replace(text3, "-");
						regex = new Regex("^\\-{1,}(\\w)", RegexOptions.IgnorePatternWhitespace);
						text3 = regex.Replace(text3, "$1");
						regex = new Regex("(\\w)\\-{1,}$", RegexOptions.IgnorePatternWhitespace);
						text3 = regex.Replace(text3, "$1");
						bool flag3 = text3.IndexOf('-') > -1;
						if (flag3)
						{
							string text4 = text3.Substring(0, text3.IndexOf('-'));
							text4 = ((text4.Length == 1) ? ("0" + text4) : text4);
							text4 = ((text4.Length == 2) ? ("19" + text4) : text4);
							text4 = ((text4.Length > 4) ? text4.Substring(0, 4) : text4);
							text3 = text4 + "-" + text3.Substring(text3.IndexOf('-') + 1);
						}
						else
						{
							text3 += "-1-1";
						}
						try
						{
							dateTime = new DateTime?(Convert.ToDateTime(text3));
						}
						catch
						{
							dateTime = null;
						}
					}
				}
				return dateTime;
			}
		}

		// Token: 0x170000CE RID: 206
		// (get) Token: 0x0600021B RID: 539 RVA: 0x0000F2C0 File Offset: 0x0000D4C0
		public string MD5
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = "";
				}
				else
				{
					bool flag2 = string.IsNullOrWhiteSpace(this._paravlue.ToString());
					if (flag2)
					{
						text = "";
					}
					else
					{
						MD5 md = global::System.Security.Cryptography.MD5.Create();
						byte[] array = md.ComputeHash(Encoding.UTF8.GetBytes(this._paravlue.ToString()));
						string text2 = string.Empty;
						for (int i = 0; i < array.Length; i++)
						{
							text2 += array[i].ToString("x2");
						}
						text = text2;
					}
				}
				return text;
			}
		}

		// Token: 0x170000CF RID: 207
		// (get) Token: 0x0600021C RID: 540 RVA: 0x0000F364 File Offset: 0x0000D564
		public string SHA1
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = null;
				}
				else
				{
					text = FormsAuthentication.HashPasswordForStoringInConfigFile(this._paravlue.ToString(), "SHA1");
				}
				return text;
			}
		}

		// Token: 0x170000D0 RID: 208
		// (get) Token: 0x0600021D RID: 541 RVA: 0x0000F39C File Offset: 0x0000D59C
		public string UrlDecode
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = null;
				}
				else
				{
					text = HttpUtility.UrlDecode(this._paravlue.ToString().Trim());
				}
				return text;
			}
		}

		// Token: 0x170000D1 RID: 209
		// (get) Token: 0x0600021E RID: 542 RVA: 0x0000F3D4 File Offset: 0x0000D5D4
		public string UrlEncode
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = null;
				}
				else
				{
					text = HttpUtility.UrlEncode(this._paravlue.ToString().Trim());
				}
				return text;
			}
		}

		// Token: 0x170000D2 RID: 210
		// (get) Token: 0x0600021F RID: 543 RVA: 0x0000F40C File Offset: 0x0000D60C
		public string HtmlDecode
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = null;
				}
				else
				{
					HttpContext httpContext = HttpContext.Current;
					text = httpContext.Server.HtmlDecode(this._paravlue.ToString());
				}
				return text;
			}
		}

		// Token: 0x170000D3 RID: 211
		// (get) Token: 0x06000220 RID: 544 RVA: 0x0000F44C File Offset: 0x0000D64C
		public string MapPath
		{
			get
			{
				return Server.MapPath(this._paravlue.ToString());
			}
		}

		// Token: 0x170000D4 RID: 212
		// (get) Token: 0x06000221 RID: 545 RVA: 0x0000F470 File Offset: 0x0000D670
		public string VirtualPath
		{
			get
			{
				return Server.VirtualPath(this._paravlue.ToString());
			}
		}

		// Token: 0x06000222 RID: 546 RVA: 0x0000F494 File Offset: 0x0000D694
		public string[] Split(char split)
		{
			return this._paravlue.ToString().Split(new char[] { split });
		}

		// Token: 0x170000D5 RID: 213
		// (get) Token: 0x06000223 RID: 547 RVA: 0x0000F4C0 File Offset: 0x0000D6C0
		[Obsolete]
		public string JavascriptTime
		{
			get
			{
				bool flag = this._paravlue == null;
				string text;
				if (flag)
				{
					text = "";
				}
				else
				{
					try
					{
						DateTime dateTime = this.DateTime ?? TimeZone.CurrentTimeZone.ToLocalTime(global::System.DateTime.Now);
						string text2 = "ddd MMM d HH:mm:ss 'UTC'zz'00' yyyy";
						CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture("en-US");
						string text3 = dateTime.ToString(text2, cultureInfo);
						text = text3;
					}
					catch
					{
						text = "";
					}
				}
				return text;
			}
		}

		// Token: 0x170000D6 RID: 214
		// (get) Token: 0x06000224 RID: 548 RVA: 0x0000F550 File Offset: 0x0000D750
		public long TimeStamp
		{
			get
			{
				DateTime dateTime = this.DateTime ?? global::System.DateTime.Now;
				DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
				return (long)(dateTime - dateTime2).TotalMilliseconds;
			}
		}

		// Token: 0x06000225 RID: 549 RVA: 0x0000F5B0 File Offset: 0x0000D7B0
		public object ChangeType(Type type)
		{
			string fullName = type.FullName;
			string text = fullName;
			object obj;
			if (!(text == "System.DateTime"))
			{
				obj = Convert.ChangeType(this._paravlue, type);
			}
			else
			{
				obj = this.DateTime;
			}
			return obj;
		}

		// Token: 0x06000226 RID: 550 RVA: 0x0000F5FC File Offset: 0x0000D7FC
		public ConvertToAnyValue Decrypt()
		{
			string text = string.Empty;
			text = DataConvert.DecryptForBase64(this.UrlDecode);
			return new ConvertToAnyValue(text);
		}

		// Token: 0x06000227 RID: 551 RVA: 0x0000F628 File Offset: 0x0000D828
		public static DateTime? ToDateTime(string text)
		{
			bool flag = string.IsNullOrWhiteSpace(text);
			DateTime? dateTime;
			if (flag)
			{
				dateTime = null;
			}
			else
			{
				Regex regex = new Regex("^\\d+$");
				bool flag2 = regex.IsMatch(text.Trim());
				if (flag2)
				{
					long num = 0L;
					long.TryParse(text, out num);
					DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds((double)num);
					dateTime = new DateTime?(dateTime2);
				}
				else
				{
					dateTime = new DateTime?(global::System.DateTime.ParseExact(text, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture));
				}
			}
			return dateTime;
		}

		// Token: 0x040000A0 RID: 160
		private object _paravlue;

		// Token: 0x040000A1 RID: 161
		private string _parakey = "";

		// Token: 0x040000A2 RID: 162
		private string _unit = "";
	}
}
